var t = require("../../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../../utils/util.js")), a = getApp();

Page({
    data: {
        id: "",
        active: 0,
        page: 1,
        current_page: "",
        last_page: "",
        datas: [],
        now: "",
        showone: !1,
        password: ""
    },
    onLoad: function(t) {
        t.id && this.setData({
            id: t.id
        }), this.setData({
            now: String(Date.parse(new Date())).substring(0, 10)
        }), this.getStatus();
    },
    toSearch: function() {
        console.log(this.data.id), wx.navigateTo({
            url: "/packageD/auction/auctioneer-shop/auctioneer_shop_search/auctioneer_shop_search?id=" + this.data.id
        });
    },
    is_password: function(t) {
        this.setData({
            password: t.detail.value
        });
    },
    isCoverLayer_passwork: function() {
        wx.showModal({
            title: "提示",
            content: "不输入店铺密码无法查看店铺详情",
            success: function(t) {
                t.confirm ? (console.log("用户点击确定"), wx.navigateBack({
                    delta: 1
                })) : t.cancel && console.log("用户点击取消");
            }
        });
    },
    confirm: function() {
        if (a._isTextEmpty(this.data.password)) wx.showToast({
            duration: 1e3,
            title: "请输入密码",
            icon: "none"
        }); else {
            var t = {
                art: "verifyPassword",
                auction_id: this.data.id,
                passwd: this.data.password
            }, e = this, i = a.getNetAddresss("plugin.auction.api.index.getAuctionData");
            a._getNetWork({
                url: i,
                data: t,
                success: function(t) {
                    var a = t.data;
                    1 == a.result ? (e.setData({
                        showone: !1
                    }), e.getStatus()) : wx.showToast({
                        title: a.msg,
                        icon: "none",
                        duration: 1e3
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    toCollect: function() {
        var t = this, e = a.getNetAddresss("plugin.auction.api.index.getAuctionData"), i = {
            art: "collectionShop",
            auctioneer_id: t.data.id
        };
        a._postNetWork({
            url: e,
            data: i,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (0 == t.data.info.is_collection ? wx.showToast({
                    title: e.data.collectionShop,
                    icon: "none",
                    duration: 1e3
                }) : wx.showToast({
                    title: "取消收藏成功",
                    icon: "none",
                    duration: 1e3
                }), t.getData()) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t), wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1e3
                });
            }
        });
    },
    itemClick: function(t) {
        console.log(t.detail.index), this.setData({
            active: t.detail.index
        }), this.getSearch();
    },
    toMy: function() {
        wx.navigateTo({
            url: "/packageD/auction/auction-mine/my_index/my_index"
        });
    },
    goxiangqin: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.id.goods_id, e = this.data.id;
        wx.navigateTo({
            url: "/packageD/auction/auction/auction_good/auction_good?id=" + a + "&member_id=" + e
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page >= this.data.last_page) {
            if (1 == this.data.last_page) return;
            wx.showToast({
                title: "暂无更多",
                icon: "none",
                duration: 1e3
            });
        } else {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), this.getNextSearch();
        }
    },
    onShareAppMessage: function() {},
    getStatus: function() {
        var t = this, e = a.getNetAddresss("plugin.auction.api.index.getAuctionData"), i = {
            member_id: this.data.id
        };
        a._getNetWork({
            url: e,
            data: i,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    status: e.data.getVerify.status,
                    is_verify: e.data.getVerify.is_verify
                }), 0 == t.data.is_verify && 1 == t.data.status ? t.setData({
                    showone: !0
                }) : (t.getSearch(), t.getData())) : wx.showToast({
                    title: res.msg,
                    icon: "none",
                    duration: 1e3,
                    success: function() {
                        setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1e3);
                    }
                });
            },
            fail: function(t) {
                console.log(t), wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1e3
                });
            }
        });
    },
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.auction.api.index.getAuctionData"), i = {
            member_id: this.data.id,
            art: "shop"
        };
        a._postNetWork({
            url: e,
            data: i,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (console.log(e), t.setData({
                    info: e.data.shop
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3,
                    success: function() {
                        setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 500);
                    }
                });
            },
            fail: function(t) {
                console.log(t), wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1e3
                });
            }
        });
    },
    getSearch: function() {
        var e, i = this, o = {
            auctioneer_id: this.data.id,
            page: this.data.page
        };
        0 == i.data.active ? e = a.getNetAddresss("plugin.auction.api.auction.all") : 1 == i.data.active ? e = a.getNetAddresss("plugin.auction.api.auction.biding") : 2 == i.data.active ? e = a.getNetAddresss("plugin.auction.api.auction.bid") : 3 == i.data.active && (e = a.getNetAddresss("plugin.auction.api.auction.finish")), 
        a._getNetWork({
            url: e,
            data: o,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    if (console.log(e), e.data.data.length > 0) for (var o = 0; o < e.data.data.length; o++) e.data.data[o].endTime = t.default.formatTimeTwo(e.data.data[o].end_shooting, "Y-M-D h:m:s"), 
                    e.data.data[o].startTime = t.default.formatTimeTwo(e.data.data[o].start_shooting, "Y-M-D h:m:s");
                    i.setData({
                        current_page: e.data.current_page,
                        last_page: e.data.last_page,
                        datas: e.data.data
                    });
                } else wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t), wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1e3
                });
            }
        });
    },
    getNextSearch: function() {
        var e, i = this, o = {
            auctioneer_id: this.data.id,
            page: this.data.page
        };
        0 == i.data.active ? e = a.getNetAddresss("plugin.auction.api.auction.all") : 1 == i.data.active ? e = a.getNetAddresss("plugin.auction.api.auction.biding") : 2 == i.data.active ? e = a.getNetAddresss("plugin.auction.api.auction.bid") : 3 == i.data.active && (e = a.getNetAddresss("plugin.auction.api.auction.finish")), 
        a._getNetWork({
            url: e,
            data: o,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    if (console.log(e), e.data.data.length > 0) for (var o = 0; o < e.data.data.length; o++) e.data.data[o].endTime = t.default.formatTimeTwo(e.data.data[o].end_shooting, "Y-M-D h:m:s"), 
                    e.data.data[o].startTime = t.default.formatTimeTwo(e.data.data[o].start_shooting, "Y-M-D h:m:s");
                    i.setData({
                        current_page: e.data.current_page,
                        last_page: e.data.last_page,
                        datas: i.data.datas.concat(e.data.data)
                    });
                } else wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t), wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1e3
                });
            }
        });
    }
});